home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1993 November / JCSM Shareware Collection - 1993-11.iso / cl720 / bxprntjj.lzh / TEST2.C < prev   
C/C++ Source or Header  |  1990-12-10  |  2KB  |  38 lines

  1. /* !!!!!!!!!!!!!! Type:   BOXPRINT/FORMAT(A) TEST2 !!!!!!!!!!!!!!!!!!!!!!*/
  2. /* An integer MandelBrot set Program. *//* Works with EGA and VGA.            */
  3. #include <stdio.h>
  4. #include <graph.h>
  5. #define not !
  6. #define forever while (1)
  7. #define MAX_ITERATIONS 30
  8. #define MAX_BOUND 10000
  9. typedef unsigned char uchar;
  10. typedef unsigned int boolean;
  11. typedef uchar * string;
  12. typedef unsigned long ulong;
  13. typedef int coord;typedef long dcoord;typedef struct{coord x,y;}point;
  14. struct videoconfig vc;point ScreenSize,Cursor,Centre,Scale;float RealX,
  15. RealY, Mag;int ScatX[640],ScatY[480];int under[20];char name[12]={"\0"};
  16. char buf[80];long new_colors[16]={0x000000,0x252A26,0x37343F,0x3F3F3F,
  17. 0x2E333F,0x00003F,0x00273F,0x00363F,0x003F3F,0x003F26,0x2A3F00,0x3F271B,
  18. 0x3F0000,0x3F002B,0x350A35,0x3F003F};void DoPixel(int x,int y);
  19. /* Colour in one pixel. */boolean ClearScreen(void);
  20. /************ Initialisation routines *********************/
  21. void assert(boolean c){if(not c)fprintf(stderr,"Error!\007");}void Swap(int
  22. *a,int*b){register int c;c=*a;*a=*b;*b=c;}void Init(void){int i;if(not
  23. ClearScreen()){printf("Not supported.");exit(0);}_getvideoconfig(&vc);
  24. ScreenSize.x=vc.numxpixels;ScreenSize.y=vc.numypixels;Mag = 1;/* Magnification    */
  25. Centre.x=ScreenSize.x/2;/* Centre of screen */
  26. Centre.y=ScreenSize.y/2;ScreenSize.y--;
  27. /* We decrement this to obtain *//* two relatively prime numbers*/
  28. /* for the screen dimensions.  */
  29. /*------ Shuffle the  Scat  ('scatter') array. ------*/for(i=0;i<
  30. ScreenSize.x;i++)ScatX[i]=i;for(i=0;i<ScreenSize.y;i++)ScatY[i]=i;
  31. for(i=0;i<ScreenSize.x;i++)Swap(&ScatX[i],&ScatX[rand()%ScreenSize.x]);
  32. for(i=0;i<ScreenSize.y;i++)Swap(&ScatY[i],&ScatY[rand()%ScreenSize.y]);
  33. Scale.x=ScreenSize.x*Mag/4;Scale.y=ScreenSize.y*Mag/4;}boolean ClearScreen
  34. (void){boolean r;if(not _setvideomode(_VRES16COLOR))/* First try VGA. */
  35. r=_setvideomode(_ERESCOLOR);/* Then try EGA   */_remapallpalette(new_colors);
  36. }
  37. /**************** Picture-drawing routines ******************/
  38. void DoPixe╨tr, s